package com.sunny.wordstudy;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.sunny.wordstudy.lib.Stat;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;

public class DownloaderView extends Activity
  implements AdapterView.OnItemClickListener
{
  List a;
  String b = "DownloaderView";
  String c = "";
  String d = "";
  String e = "";
  final int f = 0;
  private TextView g;
  private Handler h;
  private ListView i;
  private ProgressDialog j;
  private Context k;
  private AlertDialog l;
  private Thread m;
  private int n = 0;
  private Map o = new HashMap();
  private Map p = new HashMap();
  private String q = "";
  private int r;

  private String a()
  {
    int i1 = this.q.lastIndexOf(47);
    if (i1 >= 0)
    {
      str = this.q.substring(0, i1);
      if (!(str.equals("")))
        break label36;
    }
    String str = "/";
    label36: return str;
  }

  private void b()
  {
    this.j.dismiss();
    this.j.show();
    new l(this).start();
  }

  private boolean b(String paramString)
  {
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
    HttpGet localHttpGet = new HttpGet(paramString);
    JSONArray localJSONArray;
    ArrayList localArrayList;
    label452: int i2;
    int i1;
    try
    {
      HttpEntity localHttpEntity = localDefaultHttpClient.execute(localHttpGet).getEntity();
      if (localHttpEntity == null)
        break label992;
      InputStream localInputStream = localHttpEntity.getContent();
      BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localInputStream));
      StringBuilder localStringBuilder = new StringBuilder();
      String str1 = localBufferedReader.readLine();
      if (str1 == null)
      {
        localJSONArray = new JSONArray(localStringBuilder.toString());
        localArrayList = new ArrayList();
        new String();
        if (this.q.equals("/"))
          break label1014;
        HashMap localHashMap1 = new HashMap();
        localHashMap1.put("item", getResources().getString(2131099790) + "/");
        localHashMap1.put("desc", new String("Directory <<"));
        localHashMap1.put("fulldesc", new String(""));
        localHashMap1.put("dbfile", new String(""));
        localHashMap1.put("file", "/");
        localHashMap1.put("pic", Integer.valueOf(2130837505));
        localArrayList.add(localHashMap1);
        if (a().equals("/"))
          break label1014;
        HashMap localHashMap2 = new HashMap();
        localHashMap2.put("item", getResources().getString(2131099790) + ((String)this.p.get(a())));
        localHashMap2.put("desc", new String("Directory <<"));
        localHashMap2.put("fulldesc", new String(""));
        localHashMap2.put("dbfile", new String(""));
        localHashMap2.put("file", a());
        localHashMap2.put("pic", Integer.valueOf(2130837504));
        localArrayList.add(localHashMap2);
        break label1014:
        if (i2 < localJSONArray.length())
          break label540;
        this.o.put(this.q, localArrayList);
        localInputStream.close();
        i1 = 1;
        break label1020:
      }
      label540: label844: label992: label737: label1014: localStringBuilder.append(str1 + "\n");
    }
    catch (Exception localException1)
    {
      Log.e(this.b, "Error connect", localException1);
      i1 = 0;
      break label1020:
      JSONObject localJSONObject = localJSONArray.getJSONObject(i2);
      String str2 = localJSONObject.getString("DBName");
      String str3 = localJSONObject.getString("DBNote");
      String str4 = localJSONObject.getString("FileName");
      String str5 = localJSONObject.getString("DBFile");
      String str6 = localJSONObject.getString("FileSize");
      String str7 = localJSONObject.getString("ItemCount");
      HashMap localHashMap3 = new HashMap();
      localHashMap3.put("item", str2);
      if (!(str5.endsWith(".edb")))
      {
        this.p.put(str4, str2);
        localHashMap3.put("item", str2 + " >>");
        localHashMap3.put("desc", str3);
        localHashMap3.put("fulldesc", new String(""));
        localHashMap3.put("pic", Integer.valueOf(2130837508));
        localHashMap3.put("file", str4);
        localHashMap3.put("dbfile", str5);
        localHashMap3.put("filesize", str6);
        localHashMap3.put("itemcount", str7);
        localArrayList.add(localHashMap3);
        ++i2;
      }
      Object localObject = "";
      try
      {
        String str8 = Integer.toString(Integer.parseInt(str6) / 1024) + " KB";
        localObject = str8;
        localHashMap3.put("item", str5 + "  " + ((String)localObject));
        localHashMap3.put("desc", str2 + "  Items(" + str7 + ")");
        localHashMap3.put("fulldesc", str2 + "  Items(" + str7 + ")\n" + str3);
        localHashMap3.put("pic", Integer.valueOf(2130837506));
        break label737:
        Log.e(this.b, "Empty entity");
        i1 = 0;
      }
      catch (Exception localException2)
      {
        break label844:
        i2 = 0;
      }
      break label452:
    }
    label1020: return i1;
  }

  final void a(String paramString)
  {
    this.a = new ArrayList();
    if (!(this.o.containsKey(paramString)))
    {
      this.q = paramString;
      b();
    }
    while (true)
    {
      return;
      this.q = paramString;
      this.a = ((ArrayList)this.o.get(paramString));
      this.g.setText((CharSequence)this.p.get(paramString));
      String[] arrayOfString = new String[3];
      arrayOfString[0] = "pic";
      arrayOfString[1] = "item";
      arrayOfString[2] = "desc";
      int[] arrayOfInt = new int[3];
      arrayOfInt[0] = 2131230741;
      arrayOfInt[1] = 2131230742;
      arrayOfInt[2] = 2131230743;
      SimpleAdapter localSimpleAdapter = new SimpleAdapter(this, this.a, 2130903046, arrayOfString, arrayOfInt);
      this.i.setAdapter(localSimpleAdapter);
      this.i.setOnItemClickListener(this);
    }
  }

  public void onConfigurationChanged(Configuration paramConfiguration)
  {
    super.onConfigurationChanged(paramConfiguration);
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903043);
    this.h = new Handler();
    this.j = ProgressDialog.show(this, getString(2131099662), getString(2131099663), true, true, new k(this));
    this.g = ((TextView)findViewById(2131230735));
    this.i = ((ListView)findViewById(2131230736));
    this.k = this;
    this.c = ((WifiManager)getSystemService("wifi")).getConnectionInfo().getMacAddress();
    if (this.c == null)
    {
      this.c = "";
      this.d = Stat.c();
    }
    try
    {
      int i2 = ((Integer)Build.VERSION.class.getField("SDK_INT").get(new Build.VERSION())).intValue();
      String str3 = (String)Build.class.getField("MANUFACTURER").get(new Build());
      String str4 = (String)Build.class.getField("MODEL").get(new Build());
      Build.class.getField("DEVICE").get(new Build());
      this.e = URLEncoder.encode(i2 + "_" + str3 + str4, "UTF-8");
      label264: this.q = "/";
      this.p.put(new String("/"), new String("Root"));
      b();
      return;
      String str1 = "";
      int i1 = 0;
      if (i1 >= this.c.length())
        this.c = "N" + str1.toUpperCase();
      if ((this.c.charAt(i1) != '-') && (this.c.charAt(i1) != ':'))
        str1 = str1 + this.c.charAt(i1);
      ++i1;
    }
    catch (Exception localException)
    {
      String str2 = localException.getMessage();
      System.err.print(str2);
      break label264:
    }
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    super.onCreateOptionsMenu(paramMenu);
    paramMenu.add(0, 0, 0, getResources().getString(2131099842));
    return true;
  }

  public void onItemClick(AdapterView paramAdapterView, View paramView, int paramInt, long paramLong)
  {
    this.r = paramInt;
    String str1 = (String)((Map)this.a.get(this.r)).get("dbfile");
    String str2 = (String)((Map)this.a.get(this.r)).get("file");
    if ((!(str1.endsWith(".edb"))) && (!(str1.endsWith(".zip"))))
      a(str2);
    while (true)
    {
      return;
      this.m = new u(this);
      View localView = View.inflate(this, 2130903044, null);
      TextView localTextView = (TextView)localView.findViewById(2131230738);
      localTextView.setMovementMethod(LinkMovementMethod.getInstance());
      localTextView.setText(Html.fromHtml(getString(2131099677) + ((String)((Map)this.a.get(this.r)).get("fulldesc"))));
      new AlertDialog.Builder(this).setView(localView).setTitle(getString(2131099678) + ((String)((Map)this.a.get(this.r)).get("item"))).setPositiveButton(getString(2131099792), new x(this)).setNegativeButton(getString(2131099793), null).show();
    }
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 4)
      if (this.q.length() > 1)
        a(a());
    for (int i1 = 1; ; i1 = 0)
    {
      label24: return i1;
      finish();
      break label24:
    }
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 0:
    }
    while (true)
    {
      return true;
      finish();
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     com.sunny.wordstudy.DownloaderView
 * JD-Core Version:    0.5.3
 */